package cn.bugstack.domain.activity.service.rule.factory;

import cn.bugstack.domain.activity.service.rule.IActionChain;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Title: DefaultActivityChainFactory
 * @Author lz
 * @Date 2025/8/28 12:15
 * @description: 责任链工厂
 */
@Service
public class DefaultActivityChainFactory {
    private final IActionChain actionChain;

    public DefaultActivityChainFactory(Map<String, IActionChain> actionChainGroup) {//通过这种方式构建责任链顺序
        actionChain=actionChainGroup.get(ActionModel.activity_base_action.code);
        actionChain.appendNext(actionChainGroup.get(ActionModel.activity_sku_stock_action.code));
    }
    public IActionChain openActionChain(){//返回责任链
        return this.actionChain;
    }
    @Getter
    @AllArgsConstructor
    public enum ActionModel{
        activity_base_action("activity_base_action","活动库存，时间，状态校验"),
        activity_sku_stock_action("activity_sku_stock_action","活动库存校验"),
        ;
        private final String code;
        private final String info;
    }
}
